-
Notifications
You must be signed in to change notification settings - Fork 209
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: display sent and received txs in a single table #1167
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
…e into or-condition-subgraph
…e into or-condition-subgraph
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good
...rb-token-bridge-ui/src/components/TransactionHistory/TransactionsTable/TransactionsTable.tsx
Show resolved
Hide resolved
@@ -235,18 +229,6 @@ export function TransactionsTable({ | |||
return [...newerTransactions.reverse(), ...subgraphTransactions] | |||
}, [transactions, localTransactionsKey]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
React Hook useMemo has missing dependencies: 'locallyStoredTransactions', 'pageParams.pageNumber', 'pageParams.searchString', and 'type'. Either include them or remove the dependency array.eslintreact-hooks/exhaustive-deps
do we need the other deps?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We haven't had them before but I will have a look.
Maybe @dewanshparashar can have a look as well as I don't believe I've made any changes here before.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In dependencies,
- we don't need
locallyStoredTransactions
since this state object mutates very frequently andlocalTransactionsKey (string)
is derived from it to keep things under control. pageNumber
andsearchString
can be added, but we only need this memo function to run for the very first page so adding these doesn't make a difference to the logic / result. Just that it will recalculate and do an early return for each update. It's optional.
If we go ahead with it, I'd suggest a different PR to isolate it's impact.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't need locallyStoredTransactions since this state object mutates very frequently and localTransactionsKey (string) is derived from it to keep things under control.
Then we should either memo it, or not having it as a dependencies, otherwise it make things unpredictable
pageNumber and searchString can be added, but we only need this memo function to run for the very first page so adding these doesn't make a difference to the logic / result. Just that it will recalculate and do an early return for each update. It's optional.
If they are part of the callback of useEffect, then they should be included, even if they never change
packages/arb-token-bridge-ui/src/util/withdrawals/fetchTokenWithdrawalsFromEventLogs.ts
Show resolved
Hide resolved
...rb-token-bridge-ui/src/components/TransactionHistory/TransactionsTable/TransactionsTable.tsx
Show resolved
Hide resolved
packages/arb-token-bridge-ui/src/util/withdrawals/fetchETHWithdrawalsFromEventLogs.ts
Outdated
Show resolved
Hide resolved
…e into or-condition-subgraph
return fromBlockParam + toBlockParam + searchParam | ||
} | ||
|
||
export const dedupeEvents = ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this only used in one place? Let's move it there then
partialTokenWithdrawalsFromEventLogs.map(withdrawal => | ||
const mappedTokenWithdrawalsFromEventLogs = await Promise.all( | ||
paginatedWithdrawalsFromEventLogs | ||
.filter(withdrawal => !isEthWithdrawal(withdrawal)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, I don't see why this is necessary, as we should already know if something's an eth withdrawal or a token withdrawal. So we can do the mapping first before we put them all together into a single array and then we don't need this check
] | ||
.reverse() | ||
.sort((a, b) => (a.timestamp?.gt(b.timestamp || constants.Zero) ? -1 : 1)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have another instance of sorting by timestamp
in this file. So let's extract to a function and also mention that it's descending (if I'm not mistaken):
type Timestamped = {
timestamp?: BigNumber
}
function sortByTimestampDescending(a: Timestamped, b: Timestamped) {
const aTimestamp = a.timestamp ?? constants.Zero
const bTimestamp = b.timestamp ?? constants.Zero
return aTimestamp.gt(bTimestamp) ? -1 : 1
}
// later
something.sort(sortByTimestampDescending)
…e into or-condition-subgraph
…e into or-condition-subgraph
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tested tx history panel with goerli Safe, arb goerli Safe, goerli EOA, and arb goerli EOA, all look good
In preparation for single tx history table, we merge 'sent' and 'received' tabs into one table.
We achieve this by using 'or' clause in the subgraph query. Event logs had to also be slightly modified to make 2 calls (sent and received) and be merged together.
A lot of old stuff got removed.
Testing
You should be able to see transactions sent by your address and received by your address in a single table, without the need for 'sent' and 'received' tabs.
Note that CCTP is still in its own tab. We will also merge it with other txs in a separate PR.